package com.srcptit.java.training.dungvv.btvn1;
//thuan nghich
//nguyen to
//tong cac chu so la 1 so fibo
public class B7 {
	public static int thuannghich(long n) {
        long s = 0, tmp = n;
        while (n > 0) {
            s = s * 10 + n % 10;
            n = n / 10;
        }
        if (s == tmp) {
            return 1;
        }
        return 0;
    }
	public static int ngto(long n){
		int dem = 0;
		for(int i = 1; i <= n; i++)
			if (n % i == 0)  
				dem++;
		if (dem == 2)
			return 1;
		return 0;
	}
	public static int fibo(long n){
		long tong = 0; 
		while (n > 0){
			tong = tong + n%10;
			n = n / 10; 
		}
		long f0 = 0, f1 = 1, fn = 0;
		while(fn < tong){
			fn = f0 + f1;
			f0 = f1;
			f1 = fn;
		}
		if (fn == tong)
			return 1;
		return 0;
	}
	public static void main(String [] args){
		for (long i = 10001; i < 10000000; i=i+2){
			if(fibo(i) == 1)
				if(ngto(i) == 1)
					if(thuannghich(i) == 1)
						System.out.print(i+"  ");
		}
	}
}






